package jk.zmn.proxy.proxyclass;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 *jdk动态代理
 * @author zmn
 *
 */
public class JDKProxy implements InvocationHandler{

	private Object object;
	
	public Object createProxyInstance(Object object) {
		this.object = object;
		return Proxy.newProxyInstance(object.getClass().getClassLoader()
				, object.getClass().getInterfaces(), this);
	}
	
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		//执行额外的逻辑
		System.out.println("我是日志，前置处理");
		//执行原来的逻辑
		Object invoke = method.invoke(object,args);
		return invoke;
	}

	
	
	
	
}
